/**
 * 生成GUID
 *
 * @return {*}
 */
export const Guid = function () {
    var guid = ''
    for (var i = 1; i <= 32; i++) {
        var n = Math.floor(Math.random() * 16.0).toString(16)
        guid += n
        if ((i == 8) || (i == 12) || (i == 16) || (i == 20)) {
            guid += '-'
        }
    }
    return guid
}




/**
 * 获取字符串像素值
 *
 * @param {*} str
 * @return {*} 
 */
export const GetStringWidth = function (str, fontSize) {
    var element = document.createElement('span');
    element.style.visibility = 'hidden';
    element.style.whiteSpace = 'nowrap';
    fontSize && (element.style.fontSize = fontSize);
    element.textContent = str;
    document.body.appendChild(element);
    var width = element.offsetWidth;
    document.body.removeChild(element);
    return width;
}